package com.hpin.fansea.service;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hpin.fansea.R;
import com.hpin.fansea.base.BaseActivity;
import com.hpin.fansea.utils.AbDateUtil;
import com.hpin.fansea.utils.Constant;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by Aaron on 15/9/15.
 */
public class HouseKeepingActivity extends BaseActivity {

    private EditText et_declare;
    private TextView tv_order_time;
    private TextView tv_house_address;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_service_common);

        initWidget();

    }

    private void initWidget() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);

        tv_title.setText(getResources().getString(R.string.housekeeping));

        iv_left.setOnClickListener(this);

        tv_house_address = (TextView) findViewById(R.id.tv_house_address);
        tv_order_time = (TextView) findViewById(R.id.tv_order_time);

        LinearLayout ll_order_time = (LinearLayout) findViewById(R.id.ll_order_time);

        et_declare = (EditText) findViewById(R.id.et_declare);

        Button btn_order = (Button) findViewById(R.id.btn_order);

        ll_order_time.setOnClickListener(this);

        btn_order.setOnClickListener(this);

        TextView tv_price_style = (TextView) findViewById(R.id.tv_price_style);
        tv_price_style.setText(getResources().getString(R.string.housekeeping_price));

        //房号
        tv_house_address.setText(sp.getString(Constant.projectName, "") + sp.getString(Constant.buildingNo, "")
                + sp.getString(Constant.unitNo, "") + sp.getString(Constant.houseNo, ""));
        //预约时间
        tv_order_time.setText(AbDateUtil.getStringByFormat(new Date(), AbDateUtil.dateFormatxYMD));

    }

    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {

            case R.id.iv_left:

                finish();

                break;

            case R.id.ll_order_time://选择时间


                Calendar c = Calendar.getInstance();

                new DatePickerDialog(HouseKeepingActivity.this, new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear,
                                          int dayOfMonth) {

                        String month = (monthOfYear + 1) < 10 ? "0" + (monthOfYear + 1) : (monthOfYear + 1) + "";
                        String day = dayOfMonth < 10 ? "0" + dayOfMonth : dayOfMonth + "";
//                        String currDay = year + "/" + month + "/" + day;

                        tv_order_time.setText(year + "/" + month + "/" + day);
//
//                        tv_date_attendance.setText(year + "年" + month + "月" + day + "日考勤");
//                        tv_date.setText(year + "年" + month + "月" + day + "日");

//                        if (currDay.equals(lastChoose)) {
//                            return;
//                        } else {
//                            lastChoose = currDay;
//                        }

//                        getAttendanceData(currDay);

                    }

                }, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
                        c.get(Calendar.DAY_OF_MONTH)).show();

                break;

            case R.id.btn_order://预约


            break;


        }
    }
}
